<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="shortcut icon" href="../favicon.ico" />
    
    <title>Document</title>
  </head>

  <body>
    <!-- 引入顺序必须按照先引入核心库的顺序，否则报错  -->
    <div id="root"></div>
    <script src="../js/react.development.js"></script>
    <script src="../js/react-dom.development.js"></script>
    <script src="../js/babel.min.js"></script>
    <script type="text/babel">
    class Weather extends React.Component {
         //初始化状态
        state = {isHot: false}
  
        render () {
            const {isHot} = this.state
            return (
                <div>
                    <h1 onClick = {this.reactChangeWeather}>今天{isHot ? '炎热' : '凉爽'}，并且晴朗</h1>  
                </div>
            )
        }
        // 自定义方法 写成赋值语句加箭头函数
        myChangeWeather = ()=> {
            // 状态(state)不可以直接更改
            const isHot = this.state.isHot
            // 改变isHot状态 必须通过setState更改，且是一种合并
            this.setState({isHot: !isHot})

        }
        

    }
    ReactDOM.render(<Weather/>,document.getElementById('root'))


    </script>
  </body>
</html>
